package ro.isdc.training.ejb3.student.domain;

import java.io.Serializable;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 * Enrollment composite id.
 * 
 * @author Andrei Chirila
 */
public class EnrollmentId implements Serializable {
  /**
   * Generated Serial Version UID
   */
  private static final long serialVersionUID = 2637519198453249094L;

  /**
   * Course Id
   */
  private long courseId = -1;
  
  /**
   * Student Id
   */
  private long studentId = -1;

  /**
   * @return the courseId
   */
  public long getCourseId() {
    return courseId;
  }

  /**
   * @param courseId the courseId to set
   */
  public void setCourseId(final long courseId) {
    this.courseId = courseId;
  }

  /**
   * @return the studentId
   */
  public long getStudentId() {
    return studentId;
  }

  /**
   * @param studentId the studentId to set
   */
  public void setStudentId(final long studentId) {
    this.studentId = studentId;
  }

  /**
   * @see java.lang.Object#equals(Object)
   */
  public boolean equals(final Object object) {
    if (object == this) {
      return true;
    }
    if (!(object instanceof EnrollmentId)) {
      return false;
    }
    EnrollmentId rhs = (EnrollmentId) object;
    return new EqualsBuilder().append(this.studentId, rhs.studentId).append(
        this.courseId, rhs.courseId).isEquals();
  }

  /**
   * @see java.lang.Object#hashCode()
   */
  public int hashCode() {
    return new HashCodeBuilder(817210501, -643745887).append(this.studentId)
        .append(this.courseId).toHashCode();
  }

  /**
   * @see java.lang.Object#toString()
   */
  public String toString() {
    return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append(
        "studentId", this.studentId).append("courseId", this.courseId)
        .toString();
  }
  
}
